package se.jocke.nb.log.ui;

import java.awt.event.AdjustmentEvent;
import java.awt.event.AdjustmentListener;
import javax.swing.JScrollPane;

/**
 *
 * @author jocke
 */
public final class SyncAdjustmentListener implements AdjustmentListener {

    private final JScrollPane slave;

    private final JScrollPane master;

    public SyncAdjustmentListener(JScrollPane slave, JScrollPane master) {
        this.slave = slave;
        this.master = master;
        register();
    }

    public void register() {
        this.master.getVerticalScrollBar().addAdjustmentListener(this);
    }

    @Override
    public void adjustmentValueChanged(AdjustmentEvent e) {
        slave.getVerticalScrollBar().setValue(e.getValue());
    }

}
